<template>
  <div>
    <el-container>
      <!--      侧边栏-->
      <el-aside :width="asideWidth" style="min-height: 100vh;background-color: #001529">
        <div style="width:100%;height: 60px;line-height: 60px;color: white;display: flex;flex-direction:row;align-items: center;justify-content: center">
          <img src="@/assets/logo1.png" alt="" style="width: 30px;height: 30px;">
          <span v-show="!isCollapse"  class="logo_title">图书后台管理</span>
        </div>
        <el-menu :collapse="isCollapse" :collapse-transition="false" router active-text-color="#fff" text-color="rgba(255,255,255,0.65)" background-color="#001529" style="border: none" :default-active="$route.path">
          <el-menu-item index="/">
            <i class="el-icon-house"></i>
            <span slot="title">系统首页</span>
          </el-menu-item>
          <el-submenu index="3">
            <template slot="title">
              <i class="el-icon-menu"></i>
              <span>图书管理</span>
            </template>
            <el-menu-item index="/book">图书信息</el-menu-item>
            <el-menu-item index="/category">图书分类</el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>
      <el-container>
        <!--        头部-->
        <el-header>
          <i :class="collapseicon" class="collapseicon1" style="font-size: 19px" @click="handleCollapse"></i>
          <el-breadcrumb separator-class="el-icon-arrow-right" style="margin-left: 20px">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
          </el-breadcrumb>

          <div style="flex: 1;width:0;margin-right:30px;display: flex;align-items: center;justify-content: right">
            <i class="el-icon-quanping" style="margin-right:5px;cursor:pointer;font-size: 26px" @click="this.handleFull"></i>
          </div>

        </el-header>
        <!--  主题-->
        <el-main>
          <slot name="content"></slot>
        </el-main>

      </el-container>

    </el-container>
  </div>
</template>
<script>
export default {
  name: "HomeView",
  data() {
    return {
      isCollapse: false,
      asideWidth: '200px',
      collapseicon:'el-icon-s-fold'
    };
  },
  methods:{
    handleFull() {
      const userAgent = navigator.userAgent;
      if (userAgent.includes('Chrome') || userAgent.includes('Firefox')) {
        document.documentElement.requestFullscreen();
      } else {
        this.$message.warning('只有谷歌和火狐用户可以全屏！');
      }
    },
    handleCollapse(){
      this.isCollapse = !this.isCollapse;
      this.asideWidth = this.isCollapse ? '64px' : '200px'
      this.collapseicon =  this.isCollapse ? 'el-icon-s-unfold' : 'el-icon-s-fold'
    }
  }
}
</script>

<style scoped>

.el-menu--inline .el-menu-item{
  padding-left: 49px !important;

}

.el-menu-item:hover ,.el-submenu__title:hover i,.el-submenu__title:hover span{
  color: #fff !important;
}
.el-menu-item.is-active{
  background-color: #1890ff !important;
  border-radius: 5px !important;
  width: calc(100% - 8px);
  margin-left:4px;

}
.el-menu-item.is-active i{
  margin-left:-4px;
}
.el-menu-item{
  height: 45px !important;
  line-height: 45px !important;


}
.el-submenu__title{
  height: 45px !important;
  line-height: 45px !important;
}

.el-submenu .el-menu-item{
  min-width: 0 !important;
}
.el-menu--inline .el-menu-item.is-active{
  padding-left: 45px !important;
}
.el-aside{
  transition: all 0.3s;
  box-shadow: 1px 0 4px rgba(0,21,41,15);
}

.logo_title {
  margin-left: 10px;
  font-size: 14px;
  width: 100px;
  white-space: nowrap;
}


.el-header{
  box-shadow: 2px 0 6px rgba(0,21,41,35);
  display: flex;
  align-items: center;
}
.collapseicon1:hover{
  cursor: pointer;
}


</style>